package com.aaa.behind.controller;


import com.aaa.behind.service.ITbHeadNavService;
import com.aaa.entity.TbHeadNav;
import com.aaa.util.PageInfo;
import com.aaa.util.Result;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author whj
 * @since 2023-02-01
 */
@RestController
@RequestMapping("/tb-head-nav")
public class TbHeadNavController {

    @Autowired
    private ITbHeadNavService tbHeadNavService;


    @PostMapping("fuzzySearch")
    public Result fuzzySearch(@ModelAttribute PageInfo pageInfo, TbHeadNav tbHeadNav){
        Page page = tbHeadNavService.fuzzySearch(pageInfo, tbHeadNav);
        return new Result(page);
    }

    @PostMapping("updateDisable/{headId}/{isDisable}")
    public Result updateDisable(@PathVariable Integer headId,@PathVariable String isDisable){
        TbHeadNav tbHeadNav = new TbHeadNav();
        tbHeadNav.setHeadId(headId);
        tbHeadNav.setIsDisable(isDisable);
        return new Result(tbHeadNavService.updateById(tbHeadNav));
    }

    @PostMapping("removeNavigation/{headId}")
    public Result removeNavigation(@PathVariable Integer headId){
        return new Result(tbHeadNavService.removeById(headId));
    }

    @PostMapping("updateNavigation")
    public Result updateNavigation(TbHeadNav tbHeadNav){
        return new Result(tbHeadNavService.updateById(tbHeadNav));
    }

    @GetMapping("navigationSearch")
    public Result navigationSearch(){
        return new Result(tbHeadNavService.navigationSearch());
    }

    @PostMapping("insertNavigation")
    public Result insertNavigation(TbHeadNav tbHeadNav){
        tbHeadNav.setIsDeleted("0");
        tbHeadNav.setIsDisable("0");
        tbHeadNav.setIsAdd(0);
        return new Result(tbHeadNavService.saveOrUpdate(tbHeadNav));
    }
}

